<template>
	<view class="xy-store-row">
		<view class="item flex" :style="css.tcm" @tap="onLink(item)">
			<view class="l">
				 <image :src="item.logo" class="br-10" />
<!--				<image :src="'/static/new/位图@2x(3).png'" class="new-bg" />-->
			</view>
			<view class="r m-l-auto m-t-10">
				<view class="name ts-32 tb flex">
					<view>{{item.name}}</view>
				</view>
				<view class="address ovh ts-28 m-t-15" :style="css.tcl">
					<text class="xyicon icon-loc m-r-5"></text> {{item.address}}
				</view>
				<view  class="distance ts-28 m-t-15" :style="css.tcl">
					{{$xyfun.distance(item.distance)}}
					<text  class="more ts-24 flex tc-w" :style="css.prbg" v-if="text=='当前场馆' && checkBoxShow" style="margin-left:15rpx;display:inline-block;height:38rpx;line-height:38rpx;border-radius:19rpx;padding:0 20rpx;">{{text}}</text>
				</view>
			</view>
			<view v-if="checkBoxShow" class="selected-mark">
				<image v-if="isSelected" src="https://img.tennoir.ltd/static/new/%E5%B7%B2%E9%80%89%E4%B8%AD.png" class="selected-icon" />
				<image v-else src="https://img.tennoir.ltd/static/new/%E6%9C%AA%E9%80%89%E4%B8%AD.png" class="selected-icon" />
			</view>
            <view v-if="!checkBoxShow" class="selected-mark">
                <text class="more ts-24 flex tc-w" :style="css.prbg" v-if="text=='当前场馆'" style="margin-left:15rpx;display:inline-block;height:38rpx;line-height:38rpx;border-radius:19rpx;padding:0 20rpx;">{{text}}</text>
            </view>
		</view>
	</view>
</template>
<script>
	export default {
		name: "xyStoreRow",
		props: {
			item: {
				type: Object,
			},
			text: {
				type: String,
				default: '选择场馆'
			},
			first: {
				type: Boolean,
				default: false
			},
            checkBoxShow: {
                type: Boolean,
                default: true
            }
		},
		data() {
			return {
				css: this.$xyfun.css(),
				isSelected: false
			};
		},
		created() {
			// 检查当前场馆是否被选中
			const selectedStore = uni.getStorageSync("xyvenue:store");
            if(selectedStore && this.item && selectedStore.id === this.item.id) {
				this.isSelected = true;
			}
		},
		methods: {
			onLink(store) {

				if (this.text == '选择场馆') {
					uni.setStorageSync("xyvenue:store", store);
					this.$xyfun.prePage().loadData();

					if (this.first) {
						uni.reLaunch({
							url: '/pages/index'
						})
					} else {
						// uni.switchTab({
						// 	url:'/pages/index'
						// })
						uni.navigateBack(-1)
						// this.$xyfun.back();
					}


				} else if (this.text == '当前场馆') {
					this.$xyfun.to('/pages/store/select')
				}

			},

		}
	}
</script>
<style lang="scss">
	.xy-store-row {
		.item {
			position: relative;

			.l {
				image {
					// width: 152rpx;
					// height: 152rpx;
					width: 120rpx;
					height: 120rpx;
					margin-top: 16rpx;
					margin-left: 16rpx;
				}
			}

			.r {
				width: 460rpx;

				.name {
					image {
						height: 34rpx;
					}

					.select-icon {
						width: 32rpx;
						height: 32rpx;
					}

					.more {
						height: 38rpx;
						line-height: 38rpx;
						border-radius: 19rpx;
						font-weight: normal;
						padding: 0 20rpx;
					}
				}

				.address {
					height: 30rpx;
					line-height: 30rpx;
				}
			}

			.selected-mark {
				position: absolute;
				top: 10rpx;
				right: 10rpx;

				.selected-icon {
					width: 32rpx;
					height: 32rpx;
				}
			}
		}
	}
</style>
